package priv.lirenhe.exam02.A;

public class Example01 {

	public static void main(String[] args) {
		System.out.println(stringP());
		System.out.println(stringB());
	}
	
	public static String stringP(){
		String str = "0123456789";
		String str_ = "";
		long startTime = System.currentTimeMillis();
		for(int i=0; i<50000; i++){
			str_ = str_ + str;
		}
		long endTime = System.currentTimeMillis();
		
		long usedTimeL = endTime - startTime;
		
		float usedTimeF = 0.0F;
		if(usedTimeL > 1000){
			usedTimeF = usedTimeL / 1000;
			return usedTimeF + "秒";
		}
		
		return usedTimeL + "毫秒";
	}
	
	public static String stringB(){
		String str = "0123456789";
		StringBuffer sb = new StringBuffer();
		long startTime = System.currentTimeMillis();
		for(int i=0; i<50000; i++){
			sb.append(str);
		}
		long endTime = System.currentTimeMillis();
		
		long usedTimeL = endTime - startTime;
		float usedTimeF = 0.0F;
		if(usedTimeL > 1000){
			usedTimeF = usedTimeL / 1000;
			return usedTimeF + "秒";
		}
		
		return usedTimeL + "毫秒";
	}
}

